//
//  CMapViewEx.h
//  HCHK_iphone
//
//  Created by yilong zhang on 12-1-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MapKit/MKMapView.h>
#import <MapKit/MKAnnotation.h>
#import <Mapkit/MKPinAnnotationView.h>
#import <Mapkit/MKUserLocation.h>
#import <MapKit/MKPlacemark.h>
#import "CMainPageCtrl.h"


//http://maps.googleapis.com/maps/api/geocode/json?latlng=34.284,108.947&sensor=true&language=cn-ZH

//=================================================================================================================================

@interface MapAnnotation : NSObject <MKAnnotation>
{ 
    CLLocationCoordinate2D coordinate;
    int      ncolor;
    int      ntag;
    int      nIndex;
    BOOL     bIsSelected;
    BOOL     bIsNull;
    NSString *title; 
    NSString *subtitle; 
} 
@property (nonatomic, assign) CLLocationCoordinate2D coordinate; 
@property (nonatomic, retain) NSString *title; 
@property (nonatomic, retain) NSString *subtitle; 
@property (nonatomic, assign) int  ncolor;
@property (nonatomic, assign) int  ntag;
@property (nonatomic, assign) int  nIndex;
@property (nonatomic, assign) BOOL bIsSelected;
@property (nonatomic, assign) BOOL bIsNull;

-(id)initWithCoordinate2D:(CLLocationCoordinate2D)coord;

@end

//=================================================================================================================================
@interface MapView : MKMapView

@end

//=================================================================================================================================

@protocol MapViewDelegate <NSObject>

@optional
-(void)DidUpdateMapData:(CLLocationCoordinate2D)coordinate2D Radius:(float)radius State:(int)state Info:(long long)info;
-(void)DidPinSelected:(int)index;

@end

@interface CMapViewEx : UIView <MKMapViewDelegate, MKReverseGeocoderDelegate, UIGestureRecognizerDelegate>

@property (nonatomic, assign) id<MapViewDelegate>   delegate;

@property (nonatomic, assign) MKMapView                 *m_Map;
@property (nonatomic, assign) NSMutableArray            *m_Pins;
@property (nonatomic, assign) BOOL                      m_bIsShow;
@property (nonatomic, assign) BOOL                      m_bTouchEnd;
@property (nonatomic, assign) int                       m_bInit;
@property (nonatomic, assign) double                    m_Radius;
@property (nonatomic, retain) CAddrInfo                 *m_Placemark;
@property (nonatomic, assign) int                       m_nCnt;
@property (nonatomic, assign) MapAnnotation             *m_SelPin;

@property (nonatomic, assign) long long                 m_TimerID;
@property (nonatomic, assign) long long                 m_TimerRecord;

-(void)GetCurAddress:(CLLocationCoordinate2D)cur;
-(void)GetCurAddressEx:(NSTimer*)timer;
-(void)DidTimerCame:(NSTimer*)timer;
-(void)DidGetAdresss:(CAddrInfo*)placemark Info:(long long)info;
-(void)PinTouchUpInSide:(id)sender;
-(double)GetLocationDistance:(CLLocationCoordinate2D)cur New:(CLLocationCoordinate2D)new;

-(void)ShowSelPin:(MapAnnotation*)pin;
-(void)ListenLocation:(NSNotification*)notification;

//-(void)DidLocationCame:(NSNotification*)notification;
//-(void)DidLocationMap:(NSNotification*)notification;
//-(void)DidReceiveFindMe:(NSNotification*)notification;

@end
